package com.yydm.servicecms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yydm.servicecms.entity.CrmBanner;
import com.yydm.servicecms.mapper.CrmBannerMapper;
import com.yydm.servicecms.service.ICrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author yydm
 * @since 2022-07-05
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements ICrmBannerService {

    //    查询所有banner
    @Override
    public List<CrmBanner> getAllBanner() {
//        根据id进行降序排列,显示排列之后前两条记录
//        last用于拼接sql语句 将拼接的sql语句放到语句最后面
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id")
                .last("limit 2");
        List<CrmBanner> list = baseMapper.selectList(wrapper);
        return list;
    }
}
